<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>后台管理系统</title>
	    <meta name="author" content="BaiYY"/>
	    <meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	    <meta name="renderer" content="webkit">
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap.min.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/Font/css/font-awesome.min.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/index.css"/>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/index.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/time.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap-paginator.js"></script>
	</head>
	<body>
		
		<!--右边侧栏开始-->
		<div class="right-sidebar" style="max-width: 1200px;">
			<if condition='$role gt 90'>
				<ul class="nav nav-tabs" style="margin-bottom: 16px" role="tablist">
					<li role="presentation"><a href="pay.html">充值房卡</a></li>
					<li role="presentation" class="active"><a href="payList.html">充值记录</a></li>
					<li role="presentation"><a href="paySearch.html">充值搜索</a></li>
				</ul>
			</if>
			<div class="admin_tab_cont" style="display:block;margin-top: 10px;" id="tab1">
				<section class="table-responsive">
					<table class="table table-bordered" id="list">
						<thead>
							<tr id="head">
								<th>充值者ID</th>
								<th>游戏ID</th>
								<th>微信昵称</th>
								<th>数量</th>
								<th>时间</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody id="dataList"></tbody>
					</table>
				</section>
				<div style="width: 100%;">
					<nav aria-label="Page navigation" >
						<div id="example">
							<ul id="pageShow" class="pull-left"></ul>
						</div>
					</nav>
				</div>
				<div id="bg-models">
					<div id="bg-contents">
						<i class="glyphicon glyphicon-remove" id="btn-closed"></i>
						<div class="title_dialog">系统提示！</div>
						<div class="discription_dialog">确定要删除此条记录吗？</div>
						<div class="footer_dialog">
							<button class="btn btn-primary" id="btn-ok">确定</button>
							<button class="btn btn-primary" id="btn-off">取消</button>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/javascript">
			showpage();
			function showpage(pages){
				var page=pages?pages:1;
				$.ajax({
					type:"get",
					dataType:"json",
					url:"{:U('Admin/Main/payListPage')}",
					data:{page:page},
					success:function(data){
//						console.log(data);
						var str = '';
						var time = '';
						var txt = '';
						if(data != 'error') {
							for(var i=0;i<data.data.length;i++) {
								time = getLocalTime(data.data[i].add_time);
								str +="<tr><td class='id'>"+data.data[i].user_id+"</td><td>"+data.data[i].uid+"</td><td>"+data.data[i].uname+"</td><td>"+data.data[i].number+"</td><td>"+time.toLocaleString()+"</td><td><button class='btn btn-sm btn-primary' onclick='onClick(this)'>删除</button><input type='hidden' value='"+data.data[i].id+"'/></td></tr>";
							}
							$("#dataList").html(str);
						}else{
							$("#dataList").html("没有任何数据");
						}
						
						var options = {
							currentPage: data.page,    //当前页，可以请求到数据再配置
							totalPages: data.pageSize,    //总共多少页，可以请求到数据再配置
							size:"normal",    
							bootstrapMajorVersion: 3,//bootstrap版本   
							alignment: "center", //对齐方式   
							numberOfPages:1,    //每一波显示几个
							itemTexts: function (type, page, current) {        
								switch (type) {            
									case "first": return "首页";            
									case "prev": return "上一页";            
									case "next": return "下一页";            
									case "last": return "末页";            
									case "page": return page;
								}
							},
							// 选择那页点击事件
							onPageClicked:function(event,originalEvent,type,page){
	//							console.log(page)//可以获取当前页，拿这个值去发请求即可
								showpage(page);
							},
						}
					
						$('#pageShow').bootstrapPaginator(options);
					
					}
				});
			}
			function onClick(This){
				var id=$(This).siblings('input').val();
				$("#bg-models").fadeIn();
				$("#btn-ok").on("click",function () {
					$("#bg-models").hide();
                    $.ajax({
                        type:"post",
                        url:"{:U('Admin/Main/recoderDel')}?act=pay&id="+id,
                        dataType:"json",
                        success:function(data) {
                            if(data == 'success') {
                                window.location.href="{:U('Admin/Main/payList')}";
                            }else if(data == 'error'){
                                window.location.href="{:U('Admin/Main/payList')}";
                            }
                        }
                    });
                })
                $("#btn-closed").on("click",function () {
                    $("#bg-models").hide();
                });
                $("#btn-off").on("click",function () {
                    $("#bg-models").hide();
                });
			}
		</script>
	</body>
	</html>

